object ok1 {
  def main(args: Array[String]): Unit = {
    method01()
    val matrix = new Matrix
    matrix.width = 2.2
    matrix.length = 2.51
    val res1 = matrix.method()
    println(res1.formatted("%.2f"))
    method02(4, 2)
    val res2 = method03(4.22, 3.11)
    println(res2.formatted("%.2f"))
    val res3 = method05(9, 3, '/')
    println(res3)
  }

  def method01(): Unit = {
    for (i <- 1 to 10) {
      for (j <- 1 to 8) {
        print("*")
      }
      println()
    }
  }

  def method02(m: Int, n: Int): Unit = {
    for (i <- 1 to m) {
      for (j <- 1 to n) {
        print("*")
      }
      println()
    }
  }

  def method03(width: Double, length: Double): Double = {
    width * length
  }

  def method04(n: Int): Unit = {
    if (n % 2 == 0) {
      println("是偶数")
    }
  }

  def method05(m: Int, n: Int, oper: Char): Int = {
    if (oper == '+') {
      m + n
    }
    else if (oper == '-') {
      m - n
    } else if (oper == '*') {
      m * n
    } else {
      m / n
    }
  }

  class Matrix {
    var length: Double = _
    var width: Double = _

    def method(): Double = {
      length * width
    }
  }
}
